﻿using System;
using System.Configuration;
using System.Linq;

namespace NextGenSystems.WHMCS.Website
{
    public partial class Default : System.Web.UI.Page
    {
        private string _installurl = ConfigurationManager.AppSettings["installurl"];
        private string _username = ConfigurationManager.AppSettings["Username"];
        private string _password = ConfigurationManager.AppSettings["Password"];
        private string _accesskey = ConfigurationManager.AppSettings["accesskey"];
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                try
                {
                    API whmcsapi = new API(_username,_password, _installurl, _accesskey);
                     
                    //get the first 5 customers on the system
                    var result = whmcsapi.GetClients(0, 5);
                    Repeater1.DataSource = result.Clients;
                    Repeater1.DataBind();

                    var result2 = whmcsapi.GetInvoices(90);
                    Repeater2.DataSource = result2.Invoices;
                    Repeater2.DataBind();
                    Response.Write(result2.Invoices.Count());  
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message.ToString());
                }
        }
    }
}